home *** CD-ROM | disk | FTP | other *** search
/ Planet Source Code Jumbo …e CD Visual Basic 1 to 7 / 5_2007-2008.ISO / data / Zips / BG_Antivir2104102292008.psc / BG AntiVirus 2007 / Forms / frmAlert.frm next >
Text File  |  2007-08-09  |  9KB  |  273 lines

  1. VERSION 5.00
  2. Begin VB.Form frmAlert 
  3.    BackColor       =   &H00E0E0E0&
  4.    BorderStyle     =   3  'Fixed Dialog
  5.    Caption         =   "BG Antivirus / Application Blocker"
  6.    ClientHeight    =   2790
  7.    ClientLeft      =   45
  8.    ClientTop       =   435
  9.    ClientWidth     =   8400
  10.    Icon            =   "frmAlert.frx":0000
  11.    LinkTopic       =   "Form1"
  12.    MaxButton       =   0   'False
  13.    MinButton       =   0   'False
  14.    ScaleHeight     =   2790
  15.    ScaleWidth      =   8400
  16.    ShowInTaskbar   =   0   'False
  17.    StartUpPosition =   2  'CenterScreen
  18.    Begin VB.CommandButton cmdPDeny 
  19.       Caption         =   "Al&ways Deny"
  20.       Height          =   375
  21.       Left            =   6360
  22.       TabIndex        =   6
  23.       Top             =   2160
  24.       Width           =   1815
  25.    End
  26.    Begin VB.CommandButton cmdDeny 
  27.       Caption         =   "&Deny This &Time"
  28.       Height          =   375
  29.       Left            =   4320
  30.       TabIndex        =   5
  31.       Top             =   2160
  32.       Width           =   1815
  33.    End
  34.    Begin VB.CommandButton cmdAllow 
  35.       Caption         =   "&Allow This Time"
  36.       Height          =   375
  37.       Left            =   2280
  38.       TabIndex        =   4
  39.       Top             =   2160
  40.       Width           =   1815
  41.    End
  42.    Begin VB.CommandButton cmdPAllow 
  43.       Caption         =   "A&lways Allow"
  44.       Height          =   375
  45.       Left            =   240
  46.       TabIndex        =   3
  47.       Top             =   2160
  48.       Width           =   1815
  49.    End
  50.    Begin VB.TextBox txtFilePath 
  51.       Appearance      =   0  'Flat
  52.       BackColor       =   &H00E0E0E0&
  53.       BorderStyle     =   0  'None
  54.       Enabled         =   0   'False
  55.       BeginProperty Font 
  56.          Name            =   "MS Sans Serif"
  57.          Size            =   9.75
  58.          Charset         =   0
  59.          Weight          =   400
  60.          Underline       =   0   'False
  61.          Italic          =   0   'False
  62.          Strikethrough   =   0   'False
  63.       EndProperty
  64.       ForeColor       =   &H00FF0000&
  65.       Height          =   855
  66.       Left            =   2700
  67.       Locked          =   -1  'True
  68.       MultiLine       =   -1  'True
  69.       TabIndex        =   2
  70.       Top             =   360
  71.       Width           =   5445
  72.    End
  73.    Begin VB.Label lblStatus 
  74.       BackStyle       =   0  'Transparent
  75.       Caption         =   "Prompt for Action"
  76.       BeginProperty Font 
  77.          Name            =   "MS Sans Serif"
  78.          Size            =   9.75
  79.          Charset         =   0
  80.          Weight          =   400
  81.          Underline       =   0   'False
  82.          Italic          =   0   'False
  83.          Strikethrough   =   0   'False
  84.       EndProperty
  85.       ForeColor       =   &H00FF0000&
  86.       Height          =   375
  87.       Left            =   2760
  88.       TabIndex        =   7
  89.       Top             =   1440
  90.       Width           =   4215
  91.    End
  92.    Begin VB.Label Label2 
  93.       BackStyle       =   0  'Transparent
  94.       Caption         =   "Status : "
  95.       BeginProperty Font 
  96.          Name            =   "MS Sans Serif"
  97.          Size            =   9.75
  98.          Charset         =   0
  99.          Weight          =   400
  100.          Underline       =   0   'False
  101.          Italic          =   0   'False
  102.          Strikethrough   =   0   'False
  103.       EndProperty
  104.       ForeColor       =   &H00FF00FF&
  105.       Height          =   375
  106.       Left            =   2040
  107.       TabIndex        =   1
  108.       Top             =   1440
  109.       Width           =   615
  110.    End
  111.    Begin VB.Image Image1 
  112.       Height          =   1500
  113.       Left            =   240
  114.       Picture         =   "frmAlert.frx":0CCA
  115.       Top             =   240
  116.       Width           =   1500
  117.    End
  118.    Begin VB.Label Label1 
  119.       BackStyle       =   0  'Transparent
  120.       Caption         =   "File :"
  121.       BeginProperty Font 
  122.          Name            =   "MS Sans Serif"
  123.          Size            =   9.75
  124.          Charset         =   0
  125.          Weight          =   400
  126.          Underline       =   0   'False
  127.          Italic          =   0   'False
  128.          Strikethrough   =   0   'False
  129.       EndProperty
  130.       ForeColor       =   &H00FF00FF&
  131.       Height          =   495
  132.       Left            =   2040
  133.       TabIndex        =   0
  134.       Top             =   360
  135.       Width           =   495
  136.    End
  137. End
  138. Attribute VB_Name = "frmAlert"
  139. Attribute VB_GlobalNameSpace = False
  140. Attribute VB_Creatable = False
  141. Attribute VB_PredeclaredId = True
  142. Attribute VB_Exposed = False
  143. Option Explicit
  144.  
  145. 'Dim fso As New FileSystemObject
  146. 'Dim fn As File
  147.  
  148. Private Sub Form_Load()
  149.     'Dim fso As New FileSystemObject
  150.     'MsgBox fso.GetBaseName(Command$)
  151.     'MsgBox fso.GetFileName(Command$)
  152.     
  153.     'avoid open it own file
  154.     If Command$ = "" Then End
  155.     
  156.     ' check setting
  157.     If ReadRegShell("HKCU\Software\BGAntivirus\AppBlock") = 0 Then
  158.         'not enable => allow all file
  159.         Call cmdAllow_Click
  160.     End If
  161.     
  162.     'checked => manage file
  163.     '======================
  164.     'manage all files
  165.     '======================
  166.     Dim bCount As Long
  167.     Dim i As Long
  168.     
  169.     If Val(ReadRegShell("HKCU\Software\BGAntivirus\ControlAll")) = 1 Then
  170.         Me.txtFilePath.Text = Command$
  171.         ' check setting
  172.         ' allow
  173.         Dim aCount As Long
  174.         aCount = ReadRegShell("HKCU\Software\BGAntivirus\Allow\aCount")
  175.         
  176.         For i = 1 To aCount
  177.             'in allow list
  178.             'MsgBox GetString(GetClassKey("HKEY_CURRENT_USER"), "Software\BGAntivirus\Allow", CStr(i))
  179.             If Command$ = ReadRegShell("HKEY_CURRENT_USER\Software\BGAntivirus\Allow\" & CStr(i)) Then
  180.                 Call cmdAllow_Click
  181.                 'automatically END
  182.             End If
  183.         Next
  184.         
  185.         ' deny
  186.         
  187.         'Dim i As Long
  188.         bCount = ReadRegShell("HKCU\Software\BGAntivirus\Ban\bCount")
  189.         
  190.         For i = 1 To bCount
  191.             'in ban list
  192.             'MsgBox GetString(GetClassKey("HKEY_CURRENT_USER"), "Software\BGAntivirus\Ban", CStr(i))
  193.             'Set fn = fso.GetFile(ReadRegShell("HKEY_CURRENT_USER\Software\BGAntivirus\Ban\" & CStr(i)))
  194.             'MsgBox fn.ShortPath
  195.             If Command$ = ReadRegShell("HKEY_CURRENT_USER\Software\BGAntivirus\Ban\" & CStr(i)) Then
  196.                 'Call cmdDeny_Click
  197.                 Me.lblStatus.Caption = "Application Blocked"
  198.                 Me.cmdPDeny.Enabled = False
  199.                 Me.cmdDeny.Enabled = False
  200.                 Me.cmdPAllow.Enabled = False
  201.             End If
  202.         Next
  203.     Else
  204.         'manage only BLOCKED Files
  205.         bCount = ReadRegShell("HKCU\Software\BGAntivirus\Ban\bCount")
  206.         
  207.         For i = 1 To bCount
  208.             'in ban list
  209.             If Command$ = ReadRegShell("HKEY_CURRENT_USER\Software\BGAntivirus\Ban\" & CStr(i)) Then
  210.                 'Call cmdDeny_Click
  211.                 Me.lblStatus.Caption = "Application Blocked"
  212.                 Me.cmdPDeny.Enabled = False
  213.                 Me.cmdDeny.Enabled = False
  214.                 Me.cmdPAllow.Enabled = False
  215.                 Exit For
  216.             End If
  217.         Next
  218.         'check if blocked or not
  219.         If Me.lblStatus.Caption <> "Application Blocked" Then
  220.             'not found, not block => allow
  221.             Call cmdAllow_Click
  222.         End If
  223.     End If
  224.     'New app run normal
  225.     
  226. End Sub
  227.  
  228. Private Sub cmdAllow_Click()
  229.     Shell Command$, vbNormalFocus
  230.     'MsgBox "alloe. end"
  231.     End
  232. End Sub
  233.  
  234. Private Sub cmdDeny_Click()
  235.     End
  236. End Sub
  237.  
  238. Private Sub cmdPAllow_Click()
  239.     Dim aCount As Long
  240.     aCount = Val(ReadRegShell("HKCU\Software\BGAntivirus\Allow\aCount"))
  241.         
  242.     'update count
  243.     aCount = aCount + 1
  244.     
  245.     'update in registry
  246.     Call CreateStringValue(GetClassKey("HKEY_CURRENT_USER"), "Software\BGAntivirus\Allow", 1, "aCount", CStr(aCount))
  247.     'Call CreateDwordValue(GetClassKey("HKEY_CURRENT_USER"), "Software\BGAntivirus\Allow", "aCount", aCount)
  248.     'WriteRegShell "HKEY_CURRENT_USER\Software\BGAntivirus\Allow\aCount", CStr(aCount)
  249.     
  250.     'add new app to allow list
  251.     Call CreateStringValue(GetClassKey("HKEY_CURRENT_USER"), "Software\BGAntivirus\Allow", 1, CStr(aCount), Command$)
  252.     Call cmdAllow_Click
  253.     'End
  254. End Sub
  255.  
  256. Private Sub cmdPDeny_Click()
  257.     Dim bCount As Long
  258.     bCount = Val(ReadRegShell("HKCU\Software\BGAntivirus\Ban\bCount"))
  259.     
  260.     'update count
  261.     bCount = bCount + 1
  262.     
  263.     'update in registry
  264.     Call CreateStringValue(GetClassKey("HKEY_CURRENT_USER"), "Software\BGAntivirus\Ban", 1, "bCount", CStr(bCount))
  265.     'Call CreateDwordValue(GetClassKey("HKEY_CURRENT_USER"), "Software\BGAntivirus\Ban", "bCount", bCount)
  266.     'WriteRegShell "HKEY_CURRENT_USER\Software\BGAntivirus\Ban\bCount", CStr(bCount)
  267.     
  268.     'add new app to allow list
  269.     Call CreateStringValue(GetClassKey("HKEY_CURRENT_USER"), "Software\BGAntivirus\Ban", 1, CStr(bCount), Command$)
  270.     Call cmdDeny_Click
  271.     'End
  272. End Sub
  273.